USE [TestDb]
GO
/****** Object:  Table [dbo].[Articles]    Script Date: 11/26/2010 12:14:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Articles](
	[ArticleId] [bigint] IDENTITY(1,1) NOT NULL,
	[ArticleTitle] [nvarchar](150) NULL,
	[ArticleUrl] [nvarchar](250) NULL,
	[ArticleDate] [smalldatetime] NULL,
	[ArticleText] [text] NULL,
	[Source] [nvarchar](50) NULL,
 CONSTRAINT [pk_Articles] PRIMARY KEY CLUSTERED 
(
	[ArticleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Words]    Script Date: 11/26/2010 12:14:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Words](
	[WordId] [bigint] IDENTITY(1,1) NOT NULL,
	[WordText] [nvarchar](50) NOT NULL,
 CONSTRAINT [pk_Words] PRIMARY KEY CLUSTERED 
(
	[WordId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Uniq_WordText] UNIQUE NONCLUSTERED 
(
	[WordText] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Authors]    Script Date: 11/26/2010 12:14:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Authors](
	[AuthorId] [bigint] IDENTITY(1,1) NOT NULL,
	[NameSurname] [nvarchar](50) NULL,
 CONSTRAINT [pk_Authors] PRIMARY KEY CLUSTERED 
(
	[AuthorId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AuthorArticles]    Script Date: 11/26/2010 12:14:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AuthorArticles](
	[AuthorArticlesId] [bigint] IDENTITY(1,1) NOT NULL,
	[ArticleId] [bigint] NOT NULL,
	[AuthorId] [bigint] NOT NULL,
 CONSTRAINT [pk_AuthorArticles] PRIMARY KEY CLUSTERED 
(
	[AuthorArticlesId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ArticleWords]    Script Date: 11/26/2010 12:14:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ArticleWords](
	[ArticleWordId] [bigint] IDENTITY(1,1) NOT NULL,
	[WordId] [bigint] NULL,
	[ArticleId] [bigint] NULL,
	[WordCount] [int] NULL,
 CONSTRAINT [pk_ArticleWords] PRIMARY KEY CLUSTERED 
(
	[ArticleWordId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_ArticleWords_WordCount]    Script Date: 11/26/2010 12:14:31 ******/
ALTER TABLE [dbo].[ArticleWords] ADD  CONSTRAINT [DF_ArticleWords_WordCount]  DEFAULT ((0)) FOR [WordCount]
GO
/****** Object:  ForeignKey [fk_Article_AuthorArticles]    Script Date: 11/26/2010 12:14:31 ******/
ALTER TABLE [dbo].[AuthorArticles]  WITH CHECK ADD  CONSTRAINT [fk_Article_AuthorArticles] FOREIGN KEY([ArticleId])
REFERENCES [dbo].[Articles] ([ArticleId])
GO
ALTER TABLE [dbo].[AuthorArticles] CHECK CONSTRAINT [fk_Article_AuthorArticles]
GO
/****** Object:  ForeignKey [fk_Author_AuthorArticles]    Script Date: 11/26/2010 12:14:31 ******/
ALTER TABLE [dbo].[AuthorArticles]  WITH CHECK ADD  CONSTRAINT [fk_Author_AuthorArticles] FOREIGN KEY([AuthorId])
REFERENCES [dbo].[Authors] ([AuthorId])
GO
ALTER TABLE [dbo].[AuthorArticles] CHECK CONSTRAINT [fk_Author_AuthorArticles]
GO
/****** Object:  ForeignKey [fk_Articles_ArticleWords]    Script Date: 11/26/2010 12:14:31 ******/
ALTER TABLE [dbo].[ArticleWords]  WITH CHECK ADD  CONSTRAINT [fk_Articles_ArticleWords] FOREIGN KEY([ArticleId])
REFERENCES [dbo].[Articles] ([ArticleId])
GO
ALTER TABLE [dbo].[ArticleWords] CHECK CONSTRAINT [fk_Articles_ArticleWords]
GO
/****** Object:  ForeignKey [fk_Words_ArticleWords]    Script Date: 11/26/2010 12:14:31 ******/
ALTER TABLE [dbo].[ArticleWords]  WITH CHECK ADD  CONSTRAINT [fk_Words_ArticleWords] FOREIGN KEY([WordId])
REFERENCES [dbo].[Words] ([WordId])
GO
ALTER TABLE [dbo].[ArticleWords] CHECK CONSTRAINT [fk_Words_ArticleWords]
GO
